package flexconsole.controls {
	import flash.events.Event;
	
	import mx.controls.Tree;
	
	/**
	 * Tree extension that auto adjusts its height based on the displayed content.
	 *
	 * @author ivanchoo
	 *
	 */
	public class AutoHeightTree extends Tree {
		public function AutoHeightTree() {
			super();
		}
		
		/**
		 * @private
		 */
		override protected function collectionChangeHandler(event:Event):void {
			super.collectionChangeHandler(event);
			
			if (itemsSizeChanged) {
				invalidateSize();
			}
		}
		
		/**
		 * @private
		 */
		override protected function measure():void {
			super.measure();
			height = measuredHeight = measureHeightOfItems();
		}
	
	}
}